package com.googlecode.continuity.core.client;

import java.io.Serializable;

import com.google.gwt.user.client.rpc.IsSerializable;

/**
 * A GrantedAuthority is used for authorization in the most basic level of Continuity's security system.  It holds an
 * authority or "role" which authorizes the user to access resources.  Due to the requirements imposed by the Acegi
 * security framework, some parts of continuity use a different string representation of an authority, namely the one
 * resulting from this java snippet: <code>"ROLE_" + authority.getName().toUpperCase()</code>.  Usual authority names
 * are one word lower case, however, for example "admin".
 *
 * @author Peter Schmitt <aragos@aragos.de>
 */
public class GrantedAuthority implements IsSerializable, Serializable {
// ------------------------------ FIELDS ------------------------------

  private String name;

  private int id;

// --------------------- GETTER / SETTER METHODS ---------------------

  /**
   * Returns this authority's unique id.
   *
   * @return this authority's id
   */
  public int getId() {
    return id;
  }

  /**
   * Sets this authority's unique id.
   * @param id new authority id
   */
  public void setId(int id) {
    this.id = id;
  }

  /**
   * Returns this authority's name.
   *
   * @return this authority's name
   */
  public String getName() {
    return name;
  }

  /**
   * Sets this authority's name.  The name should be a one word, lowercase descriptor such as "admin".
   *
   * @param name the authority's new name
   */
  public void setName(String name) {
    this.name = name;
  }
}
